package ExtraDemo.demo06.MyThreadPool;

//static newFixedThreadPool(int nThreads)	    创建一个指定最多线程数量的线程池

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class MyThreadPoolDemo2 {
    public static void main(String[] args) throws InterruptedException {
        //参数不是初始值，而是最大值
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        ThreadPoolExecutor threadPoolExecutor=(ThreadPoolExecutor) executorService;
        System.out.println(threadPoolExecutor.getPoolSize());
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行了");
        });

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行了");
        });
        System.out.println(threadPoolExecutor.getPoolSize());
        executorService.shutdown();
    }
}
